using System.Collections.Generic;
using Cysharp.Threading.Tasks;

namespace Processors
{
    /// <summary>
    /// 景别管理器
    /// </summary>
    // ReSharper disable once ClassNeverInstantiated.Global
    public class ProcessorManager : ContainerProcessor<IProcessor>, IProcessorManager
    {
        public ProcessorManager(IEnumerable<IProcessor> processors) : base(processors)
        {
        }

        public async UniTask<object> Run(object input)
        {
            var context = new Context();
            return await Run(input, context);
        }
        
        public async UniTask<object> Run(object input, Context context)
        {
            return await Process(input, context);
        }

        public void AddToFirst(IProcessor processor)
        {
            _processors.Insert(0, processor);
        }
    }
}